<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/a.css">
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        function dolog() {
            var username = $("#username");
            var password = $("#password");
            var role = $("#role");
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "loginCheckServlet",//url
                data: $('#logform1').serialize(),
                success: function (data) {
                    data = JSON.parse(data);//解析去转义字符
                    alert(data.msg);
                    if(data.flag=="1"){
                        location.href="AdminD.jsp";
                    }else if (data.flag=="2"){
                        location.href="Doctor.jsp";
                    }else if (data.flag=="3"){
                        location.href="家属页面.jsp";
                    }else if (data.flag=="4"){
                        location.href="游客页面.jsp";
                    }
                },
                error: function () {
                    alert("异常！");
                }
            });

        }
    </script>
</head>
<body>
<header><h1>欢迎使用!医务管理系统</h1></header>
<div>
    <section> </section>
    <aside>
        <h3>查询服务</h3>
        <form id="logform1">
            用户名：<input type="text" id="username" name="username"><br>
            密&nbsp;&nbsp;码：<input type="password" id="password" name="password"><br>
            <input hidden type="text" id="role" name="role" value="doctor">
            <a onclick="dolog()" href="#logform1">登入</a>
            <a href="注册窗口.jsp">注册</a>
        </form>
    </aside>
</div>
<footer>Copyright &copy; 2020</footer>
</body>
</html>